package com.snimay;

import java.nio.charset.Charset;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.snimay.common.SessionInterceptor;

@SpringBootApplication
@ComponentScan({"com.snimay","org.activiti"})
@EnableCaching
@Configuration
public class SampleApplication extends WebMvcConfigurerAdapter{
	

	public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
	@Autowired
	SessionInterceptor sessionInterceptor; 
	
	
	
	public static void main(String[] args) {
		SpringApplication.run(SampleApplication.class, args);
	} 
	
	@Bean
    public HttpMessageConverter<String> responseBodyConverter() {
        StringHttpMessageConverter converter = new StringHttpMessageConverter(
                Charset.forName("UTF-8"));
        return converter;
    }
	@Override
    public void configureMessageConverters(
            List<HttpMessageConverter<?>> converters) {
        super.configureMessageConverters(converters);
        converters.add(responseBodyConverter());
    }

    @Override
    public void configureContentNegotiation(
            ContentNegotiationConfigurer configurer) {
        configurer.favorPathExtension(false);
    } 
    
    
   
    
  /*  
    @Autowired
    private SessionFactory sessionFactory;
    @Bean
    public HibernateJpaSessionFactoryBean sessionFactory() {
        return new HibernateJpaSessionFactoryBean();
    }*/

	 /*** 
     * 配置拦截器 
     * @author lance 
     * @param registry 
     *//* 
    public void addInterceptors(InterceptorRegistry registry) {  
        registry.addInterceptor(sessionInterceptor).addPathPatterns("/**");  
    } /**/ 
	
}
